<{include file="top_v2.html"}>

</head>
<body>
<div id="wrap" class="pt pb message-page">
    <div class="header">
        消息
        <a href="javascript:window.history.back();" class="back"></a>
        <a href="javascript:void(0);" class="clear" id="clear">清空</a>
    </div>

    <div class="container">
        <ul id="msgList"></ul>

         <div class="empty" style="display: none" >
             <img src="img/empty-3.png" alt="" />
             <p>您还没有收到任何消息</p>
         </div>

    </div>
</div>





</body>
</html>

<script type="text/javascript">
    $(function(){
        loadData();
        $('#clear').click(function(){
            if(!window.confirm("确定清空所有信息吗？清空后不可恢复")){
                return false;
            }
            $.getJSON("<{U('Notice/delAll')}>",function(data){
                if(data.status==0){
                    $('#msgList').hide();
                    $('.empty').show();
                }
                tip(data.msg);
            });
        });
        $(window).scroll(function(){
            scroll_load({page:page});
        });
    });


    var page=1;
    var loadFlag=1;
    var flagData=true;
    function loadData(){
        if(loadFlag == 0){
            return false;
        }
        flagData=false;
        $.getJSON("<{U('Notice/loadmore')}>", {page: page}, function (data) {
            flagData=true;
            if (data.status == 1) {
                tip("数据获取失败，请稍后重试或联系管理员解决！");
            } else if (data.status == 0) {
                if (data.total < 1) {
                    $('#msgList').hide();
                    $('.empty').show();
                } else {
                    page++;
                    $('#msgList').append(data.dataHTML).show();
                    $('.empty').hide();
                    if(data.isPage == 0){
                        loadFlag=0;
                    }
                }
            } else {
                tip("数据获取失败，请稍后重试或联系管理员解决！");
            }
        });
    }

    var tmp_scroll = 0;
    //拖动加载
    function scroll_load(){
        if (tmp_scroll == $(window).height() + $(window).scrollTop()) {
            return;
        }
        tmp_scroll = $(window).height() + $(window).scrollTop();
        var jia_scroll = $(document).height() - ($(window).height() + $(window).scrollTop());
        if (jia_scroll < 100 && flagData) {
            loadData();
        }
    }


</script>
